#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
void meau()
{
	printf("##########################\n");
	printf("######1.进行游戏 ########\n");
	printf("######0.退出游戏 ##########\n");
	printf("##########################\n");
	printf("######  请选择:> ##########\n");
}

void game()
{
	int guess = 0;
	int r = rand() % 100 + 1;
    int count=5;
	while (count)
	{
        printf("你有5次机会");
        printf("还剩%d次机会"，count);
		printf("请猜数字");
		scanf("%d", &guess);
		if (guess > r)
		{
			printf("猜大了\n");
		}
		else if (guess < r)
		{
			printf("猜小了\n");
		}
		else
		{
			printf("恭喜你，猜对了\n");
			break;
		}
        count--;
        if(count==0)
        {
            printf("很遗憾你的机会已经用尽");
            printf("正确数字是%d",r);
        }


	}

}

int main()
{
	srand((unsigned int)time(NULL));
	//srand((unsigned int)time(NULL));//设置随机数
	int input;

	do
	{
		meau();//调用函数
		scanf("%d", &input);
		switch (input)
		{
		case 1:
			printf("开始游戏\n");
			game();
			break;
		case 0:
			printf("退出游戏\n");
			break;
		default:
			printf("输入错误，请重新输入。\n");
			break;
		}

	} while (input);
	return 0;

}
